import requests
from lxml import etree
headers = {
                'accept-language': 'zh-CN,zh;q=0.9',
                'cache-control': 'max-age=0',
                'cookie': 'Hm_lvt_c3acb27768b401b6598a1ae2797371a4=1693548649,1693581545; '
                          'Hm_lpvt_c3acb27768b401b6598a1ae2797371a4=1693581548',
                'sec-fetch-dest': 'document',
                'sec-fetch-mode': 'navigate',
                'sec-fetch-site': 'same-origin',
                'sec-fetch-user': '?1',
                'upgrade-insecure-requests': '1',
                'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/'
                              '537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/'
                              '537.36 SLBrowser/7.0.0.6251 SLBChan/124'}

response = requests.get(url='https://mtri.bupt.edu.cn/content/content.php?p=8_17_242',
                        headers=headers)
content = response.text
tree = etree.HTML(content)
mayuan_detail_list = tree.xpath('//div[@class="content padtb10"]/table/tbody/tr/td[1]/a/@href | //'
                                'div[@class="content padtb10"]/table/tbody/tr/td[2]/a/@href | //'
                                'div[@class="content padtb10"]/table/tbody/tr/td[3]/a/@href')
mayuan_img_list = tree.xpath('//div[@class="content padtb10"]/table/tbody/tr/td[1]/a/img/@src | //'
                             'div[@class="content padtb10"]/table/tbody/tr/td[2]/a/img/@src | //'
                             'div[@class="content padtb10"]/table/tbody/tr/td[3]/a/img/@src')
for img in mayuan_img_list:
    print('https://mtri.bupt.edu.cn'+img)
for i in range(len(mayuan_detail_list)):
    content = requests.get(url=mayuan_detail_list[i], headers=headers).text
    tree = etree.HTML(content)
    mayuan_gerenjainli_list=(tree.xpath('//div[@class="content padtb10"]/p/span/span/text()'))
    print(mayuan_gerenjainli_list)
for i in range(len(mayuan_detail_list)):
    content = requests.get(url=mayuan_detail_list[i], headers=headers).text
    tree = etree.HTML(content)
    mayuan_email_list=(tree.xpath('//div[@class="content padtb10"]/p/span/span/a/@href'))
    print(mayuan_email_list)
for i in range(len(mayuan_detail_list)):
    content = requests.get(url=mayuan_detail_list[i], headers=headers).text
    tree = etree.HTML(content)
    mayuan_email_list=(tree.xpath('//div[@class="content padtb10"]/p/span/span/a/@href'))
    print(mayuan_email_list)
